package at.socialconference.web.client.ui;

import java.util.HashMap;

import at.socialconference.inter.model.Place;

import com.google.gwt.user.client.ui.ListBox;

public class ListBoxPlaces extends ListBox {
	private HashMap<Integer, Place> mapPlaces = new HashMap<Integer, Place>();
	public void addPlace(Place place) {
		mapPlaces.put(place.getId(), place);
		addItem(place.getName(), place.getId().toString());
	}
	public Place getSelectedPlace() {
		try {
			int id = Integer.parseInt(getValue(getSelectedIndex()));
			return mapPlaces.get(id);
		} catch (Exception e) {
			return null;
		}
	}
}